<%= form_for(@payment, url:
		if action_name == "new"
			invoice_payments_path
		else
			invoice_payment_path
		end
) do |f| %>
  <% if @payment.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@payment.errors.count, "error") %> prohibited this payment from being saved:</h2>

      <ul>
      <% @payment.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :amount %><br>
    <%= f.text_field :amount %>
  </div>
  <div class="field">
    <%= f.label :payment_method_id %><br>
    <%= f.collection_select(:payment_method_id, PaymentMethod.all, :id, :label, prompt: true) %>
    <%= link_to 'New Payment Method', new_invoice_payment_method_path %>
  </div>
  <div class="field">
    <%= f.label :card_number %><br>
    <%= f.number_field :card_number %>
  </div>
  <div class="field">
    <%= f.label :card_provider_id %><br>
    <%= f.collection_select(:card_provider_id, CardProvider.all, :id, :label, prompt: true) %>
    <%= link_to 'New Card Provider', new_invoice_card_provider_path %>
  </div>
  <div class="field">
    <%= f.label :card_transaction_ref %><br>
    <%= f.text_field :card_transaction_ref %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
